/*****************************************************************************
 * HUSONG PROPRIETARY INFORMATION
 * <p/>
 * The information contained herein is proprietary to HUSONG
 * and shall not be reproduced or disclosed in whole or in part
 * or used for any design or manufacture
 * without direct written authorization from HUSONG.
 * <p/>
 * Copyright (c) 2015 by HUSONG.  All rights reserved.
 *****************************************************************************/
package com.husong.controller;

import com.husong.controller.base.BaseController;
import com.husong.entity.Order;
import com.husong.enums.AuthodType;
import com.husong.pojo.ReturnJsonBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 首页
 *
 * @author maxmin
 */
@Controller
@RequestMapping()
public class IndexController extends BaseController {


    @RequestMapping("/index")
    @ResponseBody
    public ReturnJsonBean index(Integer type,String cityname,String lastDate,Long lastorderid) {
        ReturnJsonBean rb = new ReturnJsonBean();
        try {
            List<Order> list = orderService.findAll(type,cityname,lastDate,lastorderid);
            rb.setData(list);
            returnSuccess(rb);
        } catch (Exception e) {
            e.printStackTrace();
            saveException(AuthodType.jincongmin.getName(), "IndexController", "index()", e);
        }
        return rb;
    }

    @RequestMapping("/broker/count")
    @ResponseBody
    public ReturnJsonBean brokerCount(String cityname) {
        ReturnJsonBean rb = new ReturnJsonBean();
        try {
            Long count = userService.brokerCount(cityname);
            Map<String, Object> map = new HashMap<String, Object>();
            rb.setData(map);
            returnSuccess(rb);
        } catch (Exception e) {
            e.printStackTrace();
            saveException(AuthodType.jincongmin.getName(), "IndexController", "index()", e);
        }
        return rb;
    }
}
